// const baseUrl =  process.env.NODE_ENV === 'development' ? '/api' : 'https://ugeego.youjixiaoyang.com/api'
const baseUrl = 'https://ugeego.youjixiaoyang.com/api'
// const baseUrl = 'https://test.youjixiaoyang.com/api' 
export const myRequest = (options) => {
	return new Promise((resolve, reject) => {
		uni.request({
			header: {
				'content-type': 'application/json',
				// 秘钥
				'token':  uni.getStorageSync('token'),
				// 经纬度
				'lat':uni.getStorageSync('lat'),
				'long':uni.getStorageSync('long'),
				// 邀请码
				'scene':uni.getStorageSync('scene')
			},
			method: options.method || 'GET',
			data: options.data || {},
			url: baseUrl + options.url,
			complete: (complete) => {
				console.log('complete.statusCode', complete.statusCode)

			},
			success(res) {
				resolve(res)
				console.log('successres', res);
			},
			fail(err) {
				console.log(err);
				uni.showToast({
					title: '请求失败，请稍后再试',
					 icon: 'none'
				})
				reject(err)
			}
		})
	})
}
export default myRequest
